package com.sx.micowell.framework.adapter.binding;

import androidx.databinding.BindingAdapter;

import com.sx.micowell.framework.adapter.binding.adapter.BasePagerAdapter;
import com.sx.micowell.framework.adapter.binding.adapter.MyBannerAdapter;
import com.sx.micowell.framework.adapter.binding.bean.BannerResponse;
import com.sx.widget.view.UIndicator;
import com.tmall.ultraviewpager.UltraViewPager;

import java.util.List;

public class UltraViewPagerBinding {

    @BindingAdapter(value = {"tra_uIndicator", "tra_data", "tra_radius"}, requireAll = false)
    public static void setBannerData(UltraViewPager armBanner, UIndicator uIndicator, List<BannerResponse> bannerData, boolean tra_radius) {
        if (armBanner != null) {
            if (bannerData != null && bannerData.size() > 0) {
                armBanner.setScrollMode(UltraViewPager.ScrollMode.HORIZONTAL);
                MyBannerAdapter myBannerAdapter = new MyBannerAdapter(armBanner.getContext(), bannerData);
                if (tra_radius) {
                    myBannerAdapter.Noradius = tra_radius;
                }
                armBanner.setAdapter(myBannerAdapter);
                if (uIndicator != null) {
                    uIndicator.attachToViewPager(armBanner.getViewPager());
                }
            }
        }
    }

    @BindingAdapter(value = {"traIndicator", "traAdapter", "traList"}, requireAll = true)
    public static void bindBannerData(UltraViewPager ultraViewPager, UIndicator uIndicatorId, BasePagerAdapter pagerAdapter, List list) {
        if (ultraViewPager != null) {
            if (list != null && list.size() > 0) {
                pagerAdapter.setmData(list);
                ultraViewPager.setAdapter(pagerAdapter);
                uIndicatorId.attachToViewPager(ultraViewPager.getViewPager());
            }
        }
    }


}
